﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

namespace GVCSMTemplates
{
    public class CalculateTableInformationWithoutImage
    {
        public DataTable tableRowsForWithoutImageScreen1SessionQ1(DataTable dt)
        {
            DataTable resultTable = new DataTable();
            resultTable = dt.Clone();
            resultTable.Clear();
            if (dt.Rows.Count < 7 && dt.Rows.Count > 0)
            {
                object[] iRow = dt.Rows[0].ItemArray;
                resultTable.Rows.Add(iRow);
            }
            else if (dt.Rows.Count > 6)
            {
                object[] iRow = dt.Rows[6].ItemArray;
                resultTable.Rows.Add(iRow);
            }
           
            return resultTable;
        }

        public DataTable tableRowsForWithoutImageScreen2SessionQ1(DataTable dt)
        {
            DataTable resultTable = new DataTable();
            resultTable = dt.Clone();
            resultTable.Clear();
            int size = dt.Rows.Count;
            object[] iRow = dt.Rows[16].ItemArray;
            resultTable.Rows.Add(iRow);
            return resultTable;
        }

        public DataTable retrieveTableForWithoutImageScreenTemplateQ1(DataTable dt)
        {
            int rowCount = dt.Rows.Count;
            DataTable dtNormal = new DataTable();

            if (rowCount >= 17)
            {
                IniFile ini = new IniFile(@"c:\BOX\Signbox\played.ini");
                String value = ini.ReadValue("Without Image Screen Template Q1", "played");
                if (value == "played2")
                {
                    dtNormal = tableRowsForWithoutImageScreen1SessionQ1(dt);
                    ini.WriteValue("Without Image Screen Template Q1", "played", "played1");
                }
                else
                {
                    dtNormal = tableRowsForWithoutImageScreen2SessionQ1(dt);
                    ini.WriteValue("Without Image Screen Template Q1", "played", "played2");
                }
            }
            else
            {
                dtNormal = tableRowsForWithoutImageScreen1SessionQ1(dt);
            }

            return dtNormal;
        }

        public DataTable tableRowsForWithoutImageScreen1SessionQ2(DataTable dt)
        {
            DataTable resultTable = new DataTable();
            resultTable = dt.Clone();
            resultTable.Clear();
            if (dt.Rows.Count < 8 && dt.Rows.Count > 1)
            {
                object[] iRow = dt.Rows[1].ItemArray;
                resultTable.Rows.Add(iRow);
            }
            else if (dt.Rows.Count > 7)
            {
                object[] iRow = dt.Rows[7].ItemArray;
                resultTable.Rows.Add(iRow);
            }
            return resultTable;
        }

        public DataTable tableRowsForWithoutImageScreen2SessionQ2(DataTable dt)
        {
            DataTable resultTable = new DataTable();
            resultTable = dt.Clone();
            resultTable.Clear();
            object[] iRow = dt.Rows[17].ItemArray;
            resultTable.Rows.Add(iRow);
            return resultTable;
        }

        public DataTable retrieveTableForWithoutImageScreenTemplateQ2(DataTable dt)
        {
            int rowCount = dt.Rows.Count;
            DataTable dtNormal = new DataTable();

            if (rowCount >= 18)
            {
                IniFile ini = new IniFile(@"c:\BOX\Signbox\played.ini");
                String value = ini.ReadValue("Without Image Screen Template Q2", "played");
                if (value == "played2")
                {
                    dtNormal = tableRowsForWithoutImageScreen1SessionQ2(dt);
                    ini.WriteValue("Without Image Screen Template Q2", "played", "played1");
                }
                else
                {
                    dtNormal = tableRowsForWithoutImageScreen2SessionQ2(dt);
                    ini.WriteValue("Without Image Screen Template Q2", "played", "played2");
                }
            }
            else
            {
                dtNormal = tableRowsForWithoutImageScreen1SessionQ2(dt);
            }

            return dtNormal;
        }

        public DataTable tableRowsForWithoutImageScreen1SessionQ3(DataTable dt)
        {
            DataTable resultTable = new DataTable();
            resultTable = dt.Clone();
            resultTable.Clear();
            if (dt.Rows.Count < 9 && dt.Rows.Count > 2)
            {
                object[] iRow = dt.Rows[2].ItemArray;
                resultTable.Rows.Add(iRow);
            }
            else if (dt.Rows.Count > 8)
            {
                object[] iRow = dt.Rows[8].ItemArray;
                resultTable.Rows.Add(iRow);
            }
            
            return resultTable;
        }

        public DataTable tableRowsForWithoutImageScreen2SessionQ3(DataTable dt)
        {
            DataTable resultTable = new DataTable();
            resultTable = dt.Clone();
            resultTable.Clear();
            object[] iRow = dt.Rows[18].ItemArray;
            resultTable.Rows.Add(iRow);
            return resultTable;
        }

        public DataTable retrieveTableForWithoutImageScreenTemplateQ3(DataTable dt)
        {
            int rowCount = dt.Rows.Count;
            DataTable dtNormal = new DataTable();

            if (rowCount >= 19)
            {
                IniFile ini = new IniFile(@"c:\BOX\Signbox\played.ini");
                String value = ini.ReadValue("Without Image Screen Template Q3", "played");
                if (value == "played2")
                {
                    dtNormal = tableRowsForWithoutImageScreen1SessionQ3(dt);
                    ini.WriteValue("Without Image Screen Template Q3", "played", "played1");
                }
                else
                {
                    dtNormal = tableRowsForWithoutImageScreen2SessionQ3(dt);
                    ini.WriteValue("Without Image Screen Template Q3", "played", "played2");
                }
            }
            else
            {
                dtNormal = tableRowsForWithoutImageScreen1SessionQ3(dt);
            }

            return dtNormal;
        }

        public DataTable tableRowsForWithoutImageScreen1SessionQ4(DataTable dt)
        {
            DataTable resultTable = new DataTable();
            resultTable = dt.Clone();
            resultTable.Clear();
            if (dt.Rows.Count < 10 && dt.Rows.Count > 3)
            {
                object[] iRow = dt.Rows[3].ItemArray;
                resultTable.Rows.Add(iRow);
            }
            else if (dt.Rows.Count > 9)
            {
                object[] iRow = dt.Rows[9].ItemArray;
                resultTable.Rows.Add(iRow);
            }
           
            return resultTable;
        }

        public DataTable tableRowsForWithoutImageScreen2SessionQ4(DataTable dt)
        {
            DataTable resultTable = new DataTable();
            resultTable = dt.Clone();
            resultTable.Clear();
            object[] iRow = dt.Rows[19].ItemArray;
            resultTable.Rows.Add(iRow);
            return resultTable;
        }

        public DataTable retrieveTableForWithoutImageScreenTemplateQ4(DataTable dt)
        {
            int rowCount = dt.Rows.Count;
            DataTable dtNormal = new DataTable();

            if (rowCount >= 20)
            {
                IniFile ini = new IniFile(@"c:\BOX\Signbox\played.ini");
                String value = ini.ReadValue("Without Image Screen Template Q4", "played");
                if (value == "played2")
                {
                    dtNormal = tableRowsForWithoutImageScreen1SessionQ4(dt);
                    ini.WriteValue("Without Image Screen Template Q4", "played", "played1");
                }
                else
                {
                    dtNormal = tableRowsForWithoutImageScreen2SessionQ4(dt);
                    ini.WriteValue("Without Image Screen Template Q4", "played", "played2");
                }
            }
            else
            {
                dtNormal = tableRowsForWithoutImageScreen1SessionQ4(dt);
            }

            return dtNormal;
        }

    }
}